package examples.tcpoly.idioms

import examples.tcpoly.monads._

trait MonadIdioms extends Idioms {
/*  def MonadIsIdiom[M[_], A](m: M[A])(implicit w: M[A] => Monad[A, M]): Idiom[M] = new Idiom[M] {
    val mm = w(m)
    import mm._
    def ^^[T](x: T): M[T] = result(x)
    def <>[S, T](f: M[S => T], a: M[S]): M[T] = for(mf <- f; ma <- a) yield mf(ma)
  }*/
  
  class MonadicIdiom[M[_]](implicit m: Monad[M]) extends Idiom[M] {
    import m._
    def ^^[T](x: T): M[T] = result(x)
    def <>[S, T](f: M[S => T], a: M[S]): M[T] = for(mf <- f; ma <- a) yield mf(ma)
  }  
}